package viewCollection;

import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridLayout;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;

import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.border.LineBorder;

public class InfoPanel {
  private JPanel panel_;
  private JTextArea info_panel_;
  
  public InfoPanel() {
    panel_ = new JPanel(new GridLayout(0,1,0,0));
    info_panel_ = new JTextArea(3,30 );
    //info_panel_.setMaximumSize(info_panel_.getPreferredSize());
    //info_panel_.setMinimumSize(info_panel_.getPreferredSize());
    info_panel_.setPreferredSize(info_panel_.getPreferredSize());
    info_panel_.setLineWrap(true);
    info_panel_.setWrapStyleWord (false);
    info_panel_.setEditable(false);
    //info_panel_.setFont( new Font(Font.SERIF, Font.BOLD, 30) ); 
    info_panel_.setForeground( Color.BLUE );
    panel_.add(info_panel_);
    info_panel_.setVisible(true);
    panel_.setBorder(LineBorder.createGrayLineBorder());
  }
  
  public JTextArea getTextPanel() {
    return info_panel_;
  }
  
  public JPanel getPanel() {
    return panel_;
  }
  
  public void setInfoText(Component c, String to_show) {
    c.addMouseListener(new InfoMouseListener(to_show));
  }
  
  class InfoMouseListener implements MouseListener {
    private final String to_show_;
    
    InfoMouseListener(String to_show) {
      to_show_ = to_show;
    }

    @Override
    public void mouseClicked(MouseEvent e) {
      // TODO Auto-generated method stub
      
    }

    @Override
    public void mouseEntered(MouseEvent e) {
      // TODO Auto-generated method stub
      info_panel_.setText(to_show_);
    }

    @Override
    public void mouseExited(MouseEvent e) {
      // TODO Auto-generated method stub
      info_panel_.setText("");
    }

    @Override
    public void mousePressed(MouseEvent e) {
      // TODO Auto-generated method stub
      
    }

    @Override
    public void mouseReleased(MouseEvent e) {
      // TODO Auto-generated method stub
      
    }
  }

}
